var wait = 60;
function time(o) {
	if (wait == 0) {
		o.removeAttribute("disabled");
		o.value = "免费获取验证码";
		wait = 60;
	} else {
		o.setAttribute("disabled", true);
		o.value = wait + "秒后可重新发送";
		wait--;
		setTimeout(function() {
			time(o)
		}, 1000)
	}
}

function zhmm(obj) {
	if (valNull()) {
		obj.disabled = true;
		$.ajax({
			url : "valzhmmServlet.html",
			type : "Post",
			cache : false,
			data : "phone=" + $("#userPhone").val(),
			dataype : 'text',
			success : function(msg) {
				obj.disabled = false;
				if (msg == "none") {
					$(".userPhone").remove();
					$("<label   class='error userPhone'>该用户尚未注册</label>")
							.insertAfter("#userPhone");
				}
				if(msg=="haved"){
					time(obj);
				}
			}
		});
	}

}
// 手机号验证
var phone = $("#userPhone").val();
// 验证手机号
function valfocusMobile() {
	$(".userPhone").remove();
}
function valMobileblur() {
	phone = $("#userPhone").val();
	var reg = /(^13\d{9}$)|(^14)[5,7]\d{8}$|(^15[0,1,2,3,5,6,7,8,9]\d{8}$)|(^17)[6,7,8]\d{8}$|(^18\d{9}$)/g;
	if (!reg.test(phone)) {
		$("<label   class='error userPhone'>请输入11为有效手机号</label>").insertAfter(
				"#userPhone");
	}
}
function valNull() {
	var phone = $("#userPhone").val();
	var userPwd = $("#userPwd").val();
	if (phone == "") {
		$(".userPhone").remove();
		$("<label   class='error userPhone'>手机号不能为空！</label>").insertAfter(
				"#userPhone");
		return false;
	}
	return true;
}
